﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using SampleStockWP.Models;
using SampleStockWP.StockServiceReference;

namespace SampleStockWP.Views
{
    public partial class StockYahoo : PhoneApplicationPage
    {
        //YahooServiceReference.StockQuoteSoapClient asyncWS = new YahooServiceReference.StockQuoteSoapClient();
        YahooServiceReference.StockQuoteSoap asyncWS = new YahooServiceReference.StockQuoteSoapClient();
        TickerYahoo result = new TickerYahoo();

        ProgressBar bar = new ProgressBar();

        public StockYahoo()
        {
            InitializeComponent();
            List<String> tickerList = new List<String>
            {
                "AAC","AACC","AACOU","AACOW","AAME","AAON","AAPL","AATI","AAWW","AAXJ","ABAT","ABAX","ABBC","ABCB","ABCD","ABCO","ABCW","ABFS","ABIO","ABMD","ABTL","ABVA","ACAD","ACAS","ACAT","ACCL","ACET","ACFC","ACFN","ACGL","ACHN","ACIW","ACLS","ACMR","ACNB","ACOM","ACOR","ACPW","ACRX","ACTG","ACTS","ACUR","ACWI","ACWX","ACXM","ADAT","ADBE","ADEP","ADES","ADGF","ADLR","ADP","ADPI","ADRA","ADRD","ADRE","ADRU","ADSK","ADTN","ADUS","ADVS","AEGR","AEHR","AEIS","AEPI","AERG","AERL","AETI","AEY","AEZS","AFAM","AFCB","AFCE","AFFM","AFFX","AFFY","AFOP","AFSI","AGEN","AGII","AGNC","AGYS","AHCI","AHGP","AHII","AHPI","AIMC","AINV","AIRM","AIRT","AIXG","AKAM","AKRX","ALAN","ALCO","ALGN","ALGT","ALIM","ALKS","ALLB","ALLT","ALNC","ALNY","ALOG","ALOT","ALRN","ALSK","ALTE","ALTH","ALTI","ALTR","ALVR","ALXA","ALXN","AMAC","AMAG","AMAP","AMAT","AMCC","AMCF","AMCN","AMED","AMGN","AMIC","AMKR","AMLN","AMMD","AMNB","AMOT","AMOV","AMPL","AMRB","AMRI","AMRN","AMRS","AMSC","AMSF","AMSG","AMSWA","AMTC","AMTCP","AMTD","AMWD","AMZN","ANAC","ANAD","ANAT","ANCB","ANCI","ANCX","ANDE","ANDS","ANEN","ANGN","ANGO","ANIK","ANLY","ANNB","ANSS","ANTH","ANTP","AONE","AOSL","APAC","APAGF","APEI","APFC","APKT","APOG","APOL","APPY","APRI","APSA","APWC","APWR","ARAY","ARBA","ARCC","ARCI","ARCL","ARCW","ARDNA","AREX","ARGN","ARIA","ARII","ARKR","ARLP","ARMH","ARNA","AROW","ARQL","ARRS","ARRY","ARSD","ARTC","ARTNA","ARTW","ARTX","ARUN","ARWR","ASBC","ASBI","ASCA","ASCMA","ASEI","ASFI","ASGN","ASGR","ASIA","ASMI","ASML","ASNA","ASPS","ASRV","ASRVP","ASTC","ASTE","ASTI","ASTIZ","ASTM","ASUR","ASYS","ATAI","ATAX","ATEA","ATEC","ATHN","ATHR","ATHX","ATLO","ATMI","ATML","ATNI","ATPG","ATRC","ATRI","ATRM","ATRN","ATRO","ATSG","ATVI","ATX","AUBN","AUDC","AUTC","AUTH","AUXL","AVAV","AVCA","AVEO","AVGO","AVID","AVII","AVNR","AVNW","AVTR","AWRE","AXAS","AXFN","AXTI","AZPN","BABY","BAGL","BAMM","BANF","BANFP","BANR","BARI","BASI","BBBB","BBBY","BBEP","BBGI","BBND","BBNK","BBOX","BBRG","BBSI","BBXT","BCAR","BCBP","BCDS","BCOM","BCON","BCPC","BCRX","BCSB","BCSI","BDCO","BDE","BDGE","BDMS","BDSI","BEAT","BEAV","BEBE","BECN","BELFA","BELFB","BERK","BEST","BEXP","BFED","BFIN","BFLY","BFSB","BGCP","BGFV","BGMD","BHLB","BIB","BICK","BIDU","BIDZ","BIIB","BIOC","BIOD","BIOF","BIOS","BIRT","BIS","BITS","BJRI","BKBK","BKCC","BKEP","BKMU","BKOR","BKSC","BKYF","BLDP","BLDR","BLIN","BLKB","BLTI","BLUD","BMC","BMRC","BMRN","BMTC","BMTI","BNCL","BNCN","BNHN","BNHNA","BNSO","BNVI","BOBE","BOCH","BODY","BOFI","BOKF","BOLT","BONA","BONT","BOOM","BOOT","BOSC","BOVA","BPAX","BPFH","BPFHW","BPHX","BPOP","BPOPM","BPOPN","BRCD","BRCM","BRID","BRKL","BRKR","BRKS","BRLI","BRNC","BSDM","BSET","BSFT","BSPM","BSQR","BSRR","BSTC","BTFG","BTUI","BUCY","BUSE","BVSN","BWEN","BWINA","BWINB","BWLD","BWOW","BWOWU","BWOWW","BYFC","CA","CAAS","CABL","CAC","CACB","CACC","CACH","CADC","CADX","CAFI","CAKE","CALD","CALI","CALL","CALM","CALP","CALPW","CAMP","CAMT","CAPS","CAR","CART","CARV","CARZ","CASB","CASH","CASM","CASS","CAST","CASY","CATM","CATY","CAVM","CAVO","CAZA","CAZAU","CAZAW","CBAK","CBAN","CBEY","CBIN","CBKN","CBLI","CBMX","CBMXW","CBNJ","CBNK","CBOE","CBOU","CBPO","CBRL","CBRX","CBSH","CBST","CCBD","CCBG","CCCL","CCCLU","CCCLW","CCGM","CCIH","CCIX","CCMP","CCNE","CCOI","CCRN","CCRT","CCUR","CDCS","CDII","CDNS","CDTI","CDXS","CDZI","CEBK","CECE","CECO","CEDC","CEDU","CELG","CELGZ","CELL","CENT","CENTA","CENX","CEPH","CERN","CERP","CERS","CETV","CEVA","CFBK","CFFC","CFFI","CFFN","CFK","CFNB","CFNL","CFSG","CGEN","CGNX","CHBT","CHCI","CHCO","CHDN","CHDX","CHEV","CHFC","CHFN","CHINA","CHKE","CHKP","CHLN","CHMP","CHNG","CHNR","CHOP","CHRM","CHRS","CHRW","CHSCP","CHSI","CHTP","CHTR","CHUX","CHYR","CIDM","CIEN","CIGX","CIIC","CIMT","CINF","CISG","CITZ","CIZN","CJJD","CKEC","CKSW","CKXE","CLBH","CLCT","CLDX","CLFC","CLFD","CLMS","CLMT","CLNE","CLRO","CLSN","CLUB","CLWR","CLWT","CMCO","CMCSA","CMCSK","CME","CMED","CMFB","CMLS","CMRG","CMSB","CMTL","CNAF","CNBC","CNBKA","CNET","CNIT","CNMD","CNQR","CNSL","CNTF","CNTY","CNVO","CNYD","COBK","COBR","COBZ","COCO","COGO","COHR","COHU","COIN","COINW","COINZ","COKE","COLB","COLM","COMV","CONN","COOL","CORE","CORT","COSI","COST","COWN","CPBC","CPBK","CPGI","CPHC","CPHD","CPIX","CPKI","CPLA","CPLP","CPNO","CPRT","CPRX","CPSI","CPSL","CPSS","CPST","CPTS","CPWM","CPWR","CRA","CRAI","CRAY","CRBC","CRDC","CRDN","CRED","CREE","CREG","CRESW","CRESY","CRFN","CRIC","CRIS","CRME","CRMT","CRNT","CROX","CRRB","CRRC","CRTX","CRUS","CRVL","CRWN","CRWS","CRYP","CRZO","CSBC","CSBK","CSCD","CSCO","CSFL","CSGP","CSGS","CSII","CSIQ","CSKI","CSOD","CSPI","CSTR","CSUN","CSWC","CTAS","CTBC","CTBI","CTCH","CTCM","CTCT","CTDC","CTE","CTEL","CTFO","CTGX","CTHR","CTIB","CTIC","CTICD","CTRN","CTRP","CTSH","CTWS","CTXS","CU","CUBA","CUTR","CVBF","CVBK","CVCO","CVCY","CVGI","CVGW","CVLT","CVLY","CVTI","CVV","CVVT","CWBC","CWBS","CWCO","CWEI","CWS","CWST","CWTR","CXDC","CXPO","CY","CYAN","CYBE","CYBI","CYBX","CYCC","CYCCP","CYDE","CYMI","CYNO","CYOU","CYTK","CYTR","CYTX","CYTXW","CZFC","CZNC","CZWI","DAIO","DAKT","DARA","DATE","DAVE","DBLE","DBLEP","DCIX","DCOM","DCTH","DDIC","DDSS","DEAR","DECK","DEER","DELL","DENN","DEPO","DEST","DFR","DFZ","DGAS","DGICA","DGICB","DGII","DGIT","DGLY","DHFT","DHIL","DHRM","DIET","DIOD","DISCA","DISCB","DISCK","DISH","DITC","DJCO","DLGC","DLIA","DLLR","DLTR","DMAN","DMED","DMLP","DMND","DMRC","DNBF","DNBK","DNDN","DNEX","DORM","DOVR","DPTR","DRAD","DRAM","DRCO","DRIV","DROOY","DRRX","DRWI","DRYS","DSCI","DSCM","DSCO","DSGX","DSPG","DSTI","DSWL","DTLK","DTSI","DTV","DUCK","DUSA","DVAX","DVOX","DWA","DWCH","DWSN","DXCM","DXPE","DXYN","DYAX","DYII","DYNT","DYSL","EAGLU","EBAY","EBIX","EBMT","EBSB","EBTC","EBTX","ECBE","ECGI","ECHO","ECOL","ECPG","ECTY","ECYT","EDAC","EDAP","EDGR","EDGW","EDMC","EDS","EDSWW","EDUC","EEFT","EEI","EFII","EFOI","EFSC","EFUT","EGBN","EGHT","EGLE","EGOV","EHTH","EIHI","ELGX","ELMD","ELMG","ELNK","ELON","ELOS","ELOY","ELRC","ELSE","ELTK","EMCF","EMCI","EMFN","EMIF","EMITF","EMKR","EMMS","EMMSP","EMMT","ENDP","ENER","ENG","ENMD","ENOC","ENSG","ENTG","ENTR","ENWV","ENZN","EONC","EOSPN","EPAX","EPAY","EPCT","EPHC","EPIC","EPIQ","EPOC","EQIX","ERIC","ERIE","ERII","EROC","EROCW","ERT","ERTS","ESBF","ESBK","ESCA","ESEA","ESGR","ESIC","ESIO","ESLR","ESLT","ESMC","ESRX","ESSA","ESSX","ESTE","ESYS","ETFC","ETRM","EUFN","EVBS","EVEP","EVOL","EWBC","EXAC","EXAR","EXAS","EXEL","EXFO","EXLP","EXLS","EXPD","EXPE","EXPO","EXTR","EXXI","EZCH","EZPW","FABK","FACE","FALC","FARM","FARO","FAST","FBCM","FBIZ","FBMI","FBMS","FBNC","FBSI","FBSS","FCAL","FCAP","FCBC","FCCO","FCCY","FCEL","FCFC","FCFL","FCFS","FCHI","FCLF","FCNCA","FCTY","FCVA","FCZA","FDEF","FDML","FEED","FEFN","FEIC","FEIM","FELE","FFBC","FFBCW","FFBH","FFBHD","FFCH","FFCO","FFDF","FFEX","FFFD","FFHL","FFIC","FFIN","FFIV","FFKT","FFKY","FFN","FFNM","FFNW","FHCO","FIBK","FINL","FIRE","FISI","FISV","FITB","FITBP","FIZZ","FLDM","FLEX","FLIC","FLIR","FLML","FLOW","FLWS","FLXS","FMAR","FMBI","FMCN","FMER","FMFC","FNBN","FNDT","FNFG","FNGN","FNLC","FNSR","FOLD","FONE","FONR","FORD","FORM","FORR","FORTY","FOSL","FPFC","FPIC","FPTB","FRBK","FRCCO","FRED","FREE","FREEZ","FRME","FRNK","FRP","FRPT","FSBI","FSBK","FSCI","FSFG","FSGI","FSII","FSIN","FSLR","FSRV","FSTR","FSYS","FTEK","FTLK","FTNT","FTWR","FUBC","FUEL","FULL","FULT","FUNC","FUND","FURX","FWLT","FWRD","FXCB","FXEN","GABC","GAGA","GAI","GAIA","GAIN","GAME","GASS","GBCI","GBDC","GBLI","GBNK","GCBC","GCFB","GCOM","GCVRZ","GEDU","GENC","GENE","GENT","GEOI","GEOY","GERN","GEVO","GFED","GFN","GFNCL","GFRE","GGAL","GHDX","GIFI","GIGA","GIGM","GIII","GILD","GILT","GIVN","GKNT","GKSR","GLAD","GLBC","GLBL","GLBS","GLBZ","GLCH","GLDC","GLDD","GLGL","GLNG","GLPW","GLRE","GLUU","GMAN","GMCR","GMET","GMETP","GMLP","GMTC","GNCMA","GNET","GNMK","GNOM","GNTX","GNVC","GNVCD","GOLD","GOLF","GOOD","GOODO","GOODP","GOOG","GPIC","GPOR","GPRC","GPRE","GPRO","GRAN","GRID","GRIF","GRMH","GRMN","GRNB","GROW","GRRF","GRVY","GSAT","GSBC","GSIC","GSIG","GSIT","GSLA","GSM","GSOL","GSVC","GTIM","GTIV","GTLS","GTSI","GTXI","GUID","GULF","GYRO","HA","HAFC","HAIN","HALL","HALO","HANS","HARL","HAS","HAST","HAUP","HAVNP","HAYN","HBAN","HBANP","HBCP","HBHC","HBIO","HBNC","HBNK","HBOS","HCBK","HCCI","HCII","HCIIP","HCIIW","HCKT","HCSG","HDNG","HDSN","HEAT","HEES","HELE","HEOP","HERO","HEV","HFBC","HFBL","HFFC","HFWA","HGIC","HGSH","HGSI","HHGP","HIBB","HIFS","HIHO","HILL","HIMX","HITK","HITT","HLIT","HLYS","HMIN","HMNA","HMNF","HMPR","HMPRD","HMSY","HNH","HNRG","HNSN","HOFT","HOGS","HOKU","HOLI","HOLL","HOLX","HOMB","HOME","HOOK","HOTT","HOVNP","HPCCP","HPJ","HPOL","HRBN","HRZN","HSFT","HSIC","HSII","HSKA","HSNI","HSOL","HSTM","HSWI","HTBK","HTCH","HTCO","HTGC","HTHT","HTLD","HTLF","HTWR","HUBG","HUGH","HURC","HURN","HUVL","HWAY","HWBK","HWCC","HWKN","HYGS","IACI","IART","IBB","IBCA","IBCP","IBCPO","IBKC","IBKR","IBNK","IBOC","ICAD","ICCC","ICFI","ICGE","ICGN","ICLK","ICLN","ICLR","ICOG","ICON","ICUI","IDCC","IDIX","IDRA","IDSA","IDSY","IDTI","IDXX","IESC","IFAS","IFEU","IFGL","IFNA","IFON","IFSIA","IFSM","IGLD","IGOI","IGOV","IGTE","III","IIIN","IIJI","IILG","IIN","IIVI","IKAN","IKNX","ILMN","IMGN","IMKTA","IMMR","IMMU","IMOS","IMRS","INAP","INCB","INCY","INDB","INDY","INFA","INFI","INFN","INFY","INHX","ININ","INMD","INOC","INOD","INPH","INSM","INSP","INSU","INSW","INTC","INTG","INTL","INTT","INTU","INTX","INVE","INWK","IOSP","IPAR","IPAS","IPCC","IPCI","IPCM","IPGP","IPHS","IPSU","IPXL","IRBT","IRDM","IRDMU","IRDMW","IRDMZ","IRET","IRETP","IRIS","IRIX","IRWD","ISBC","ISCA","ISHG","ISIG","ISIL","ISIS","ISLE","ISNS","ISPH","ISRG","ISRL","ISSC","ISSI","ISTA","ISYS","ITIC","ITMN","ITRI","ITRN","IVAC","IVAN","IXYS","JACK","JADE","JAKK","JASO","JAX","JAXB","JAZZ","JBHT","JBLU","JBSS","JCDA","JCOM","JCS","JCTCF","JDAS","JDSU","JFBC","JFBI","JGBO","JJSF","JKHY","JMBA","JNGW","JOBS","JOEZ","JOSB","JOUT","JOYG","JRCC","JRJC","JSDA","JST","JVA","JXSB","KALU","KAMN","KBALB","KCAP","KCLI","KELYA","KELYB","KENT","KEQU","KERX","KEYN","KEYW","KFFB","KFFG","KFRC","KGJI","KINS","KIPS","KIRK","KITD","KLAC","KLIC","KMGB","KNDI","KNDL","KNOL","KNOT","KNSY","KNXA","KONA","KONE","KONG","KOOL","KOPN","KOSS","KRNY","KSW","KSWS","KTCC","KTEC","KTOS","KUTV","KVHI","LABC","LABL","LACO","LAKE","LAMR","LANC","LARK","LAVA","LAWS","LAYN","LBAI","LBIX","LBTYA","LBTYB","LBTYK","LCAPA","LCAPB","LCAV","LCRY","LCUT","LDSH","LEAP","LECO","LEDR","LEDS","LEGC","LFUS","LGCY","LGND","LHCG","LIFE","LIME","LINC","LINE","LINTA","LINTB","LION","LIOX","LIVE","LIWA","LKFN","LKQX","LLEN","LLNW","LLTC","LMAT","LMIA","LMLP","LMNR","LMNX","LNBB","LNCE","LNCR","LNDC","LNET","LOAN","LOCM","LOGI","LOGM","LOJN","LONG","LOOK","LOOP","LOPE","LORL","LPHI","LPLA","LPNT","LPSB","LPSN","LPTH","LQDT","LRAD","LRCX","LSBI","LSBK","LSCC","LSTR","LSTZA","LSTZB","LTBR","LTON","LTRE","LTRX","LTXC","LUFK","LULU","LUNA","LVLT","LWAY","LWSN","LXRX","LYTS","LZEN","MAGS","MAIL","MAJC","MAKO","MALL","MANH","MANT","MAPP","MARPS","MASC","MASI","MAT","MATW","MAXY","MAYS","MBFI","MBLX","MBND","MBRG","MBTF","MBVT","MBWM","MCBC","MCBF","MCBI","MCGC","MCHP","MCHX","MCOX","MCRI","MCRL","MCRS","MDAS","MDCA","MDCI","MDCO","MDH","MDMD","MDRX","MDSO","MDTH","MDVN","MEAD","MEAS","MEDH","MEDW","MELA","MELI","MEMS","MENT","MEOH","MERC","MERR","MERU","METR","MFI","MFLR","MFLX","MFNC","MFRI","MFSF","MGAM","MGEE","MGIC","MGLN","MGPI","MGRC","MGYR","MHGC","MHLD","MICC","MIDD","MIND","MINI","MIPS","MITI","MITL","MITSY","MKSI","MKTAY","MKTG","MKTX","MLAB","MLHR","MLNK","MLNX","MLVF","MMLP","MMSI","MMUS","MMYT","MNDO","MNEL","MNKD","MNOV","MNRK","MNRKP","MNRO","MNTA","MNTG","MNTX","MOBI","MOCO","MOFG","MOLX","MOLXA","MORN","MOSY","MOTR","MOVE","MPAA","MPAC","MPB","MPEL","MPET","MPWR","MRCY","MRGE","MRLN","MRNA","MRTN","MRVL","MSBF","MSCC","MSDXP","MSEX","MSFG","MSFT","MSG","MSHL","MSON","MSPD","MSSR","MSTR","MSW","MTEX","MTOX","MTRX","MTSC","MTSL","MTSN","MTTX","MU","MVIS","MVISW","MWIV","MXIM","MXWL","MYGN","MYL","MYRG","MYRX","NABI","NAFC","NAII","NANO","NANX","NARA","NASB","NATH","NATI","NATL","NATR","NAUH","NAVG","NAVR","NBBC","NBIX","NBN","NBTB","NBTF","NBXH","NCBC","NCIT","NCMI","NCTY","NDAQ","NDSN","NEBS","NECB","NEI","NEOG","NEPT","NETC","NETL","NEWL","NEWP","NEWS","NEWT","NEXS","NFBK","NFEC","NFLX","NFSB","NGPC","NGSX","NHTB","NICE","NICK","NIHD","NILE","NINE","NKBP","NKSH","NKTR","NLCI","NLST","NLTX","NLTXW","NMRX","NNBR","NOBH","NOIZ","NOOF","NOVA","NOVB","NOVL","NPBC","NPBCO","NPSP","NRCI","NRIM","NSEC","NSFC","NSIT","NSPH","NSSC","NSTC","NSYS","NTAP","NTCT","NTES","NTGR","NTIC","NTLS","NTRI","NTRS","NTSC","NTSP","NTWK","NUAN","NUCL","NURO","NUTR","NUVA","NVAX","NVDA","NVEC","NVGN","NVLS","NVMI","NVSL","NVTL","NWBI","NWFL","NWK","NWLI","NWPX","NWS","NWSA","NXPI","NXST","NXTM","NYMT","NYMX","NYNY","OABC","OBAF","OBAS","OBCI","OCC","OCFC","OCLR","OCLS","OCNF","OCZ","ODFL","OFED","OFIX","OFLX","OGXI","OIIM","OINK","OKSB","OKSBP","OLBK","OLCB","OMAB","OMCL","OMER","OMEX","OMPI","ONAV","ONCY","ONEQ","ONFC","ONNN","ONSM","ONTY","ONVI","ONXX","OPEN","OPHC","OPLK","OPNT","OPOF","OPTR","OPTT","OPWV","OPXA","OPXAW","OPXT","ORBC","ORBK","ORBT","ORCC","ORCH","ORCL","ORCT","OREX","ORIT","ORLY","ORRF","OSBC","OSBCP","OSHC","OSIR","OSIS","OSN","OSTK","OSUR","OTEX","OTIV","OTT","OTTR","OUTD","OVBC","OVLY","OVRL","OVTI","OXBT","OXGN","OXLC","OXPS","OYOG","OZRK","PAAS","PABK","PACB","PACQU","PACR","PACW","PAET","PAGG","PANL","PARD","PARL","PATH","PATK","PATR","PAYX","PBCT","PBHC","PBIB","PBIO","PBIP","PBNY","PCAR","PCBC","PCBK","PCBS","PCCC","PCH","PCLN","PCOM","PCRX","PCTI","PCYC","PCYO","PDCO","PDEX","PDFS","PDII","PDLI","PEBK","PEBO","PEDH","PEET","PEGA","PEIX","PENN","PENX","PEOP","PERF","PERY","PESI","PETD","PETM","PETS","PFBC","PFBI","PFBX","PFCB","PFED","PFIN","PFLT","PFSW","PGC","PGEB","PGNX","PGTI","PHII","PHIIK","PHMD","PICO","PKBK","PKOH","PKOL","PLAB","PLBC","PLCC","PLCE","PLCM","PLFE","PLNR","PLPC","PLTM","PLUG","PLUS","PLXS","PLXT","PMBC","PMCS","PMD","PMFG","PMIC","PMNA","PMTC","PMTI","PNBC","PNBK","PNCL","PNFP","PNNT","PNNW","PNQI","PNRA","PNRG","PNSN","PNTR","PODD","POOL","POPE","POWI","POWL","POWR","POZN","PPBI","PPDI","PPHM","PRAA","PRAN","PRCP","PRFT","PRFZ","PRGO","PRGS","PRGX","PRIM","PRKR","PRLS","PRMW","PROJ","PROV","PRPH","PRSC","PRSP","PRST","PRTS","PRVT","PRWT","PRXI","PRXL","PSAU","PSBH","PSCC","PSCD","PSCE","PSCF","PSCH","PSCI","PSCM","PSCT","PSCU","PSDV","PSEC","PSEM","PSID","PSMT","PSOF","PSSI","PSTB","PSTI","PSTL","PSTR","PSUN","PTEK","PTEN","PTIE","PTIX","PTNR","PTRY","PTSI","PTSX","PULB","PURE","PVFC","PVSA","PVSW","PVTB","PVTBP","PWAV","PWER","PWND","PWOD","PWRD","PWX","PXLW","PZZA","PZZI","QABA","QADA","QADB","QBAK","QCCO","QCLN","QCOM","QCOR","QCRH","QDEL","QGEN","QKLS","QLGC","QLIK","QLTI","QLTY","QNST","QQEW","QQQ","QQQX","QQXT","QSFT","QSII","QTEC","QTWW","QUIK","RADA","RADS","RAIL","RAM","RAME","RAND","RAVN","RBCAA","RBCN","RBNF","RBPAA","RCII","RCKB","RCKY","RCMT","RCON","RCRC","RDA","RDCM","RDEA","RDEN","RDI","RDIB","RDNT","RDWR","RECN","REDF","REED","REFR","REGN","REIS","RELL","RELV","RENT","REVU","REXI","REXX","RFIL","RFMD","RFMI","RGCO","RGDX","RGEN","RGLD","RGNC","RICK","RIGL","RIMG","RIMM","RITT","RIVR","RJET","RLOC","RLOG","RLRN","RMBS","RMCF","RMKR","RMTI","RMTR","RNET","RNIN","RNOW","RNST","RNWK","ROCK","ROCM","RODM","ROIA","ROIAK","ROIC","ROICU","ROICW","ROLL","ROMA","ROSE","ROSG","ROST","ROVI","ROYL","RP","RPRX","RPTP","RPXC","RRD","RRGB","RRST","RSOL","RSTI","RSYS","RTEC","RTIX","RTLX","RUE","RURL","RUSHA","RUSHB","RUTH","RVBD","RVSB","RVSN","RXII","RYAAY","SAAS","SABA","SAFM","SAFT","SAIA","SALM","SANM","SANW","SANWW","SANWZ","SAPE","SAPX","SAPXD","SASR","SATC","SATS","SAVB","SBAC","SBBX","SBCF","SBGI","SBIB","SBIBN","SBIBW","SBLK","SBNY","SBNYW","SBRA","SBSA","SBSI","SBUX","SCBT","SCEI","SCHL","SCHN","SCHS","SCIL","SCKT","SCLN","SCMF","SCMFO","SCMP","SCMR","SCOK","SCON","SCOR","SCSC","SCSS","SCVL","SDBT","SDIX","SEAC","SEED","SEIC","SENEA","SENEB","SERV","SFLY","SFNC","SFSF","SFST","SGC","SGEN","SGI","SGMA","SGMO","SGMS","SGNT","SGOC","SGRP","SHBI","SHEN","SHFL","SHIP","SHIPW","SHLD","SHLM","SHLO","SHMR","SHOO","SHOR","SHPGY","SIAL","SIEB","SIFI","SIFY","SIGA","SIGI","SIGM","SILC","SIMG","SIMO","SINA","SINO","SIRI","SIRO","SIVB","SIVBO","SKBI","SKYW","SLAB","SLGN","SLP","SLRC","SLTC","SLTM","SLXP","SMBC","SMBL","SMCG","SMCI","SMED","SMHG","SMIT","SMMF","SMOD","SMRT","SMSC","SMSI","SMT","SMTC","SMTX","SNAK","SNBC","SNCR","SNDA","SNDK","SNFCA","SNHY","SNMX","SNPS","SNSS","SNSTA","SNTA","SNTS","SOCB","SODA","SOFO","SOHU","SOLR","SOMH","SOMX","SONA","SONC","SONE","SONO","SONS","SORL","SOXX","SPAN","SPAR","SPBC","SPCHA","SPCHB","SPEC","SPEX","SPEXD","SPIL","SPIR","SPLS","SPMD","SPNC","SPNS","SPPI","SPPR","SPPRO","SPPRP","SPRD","SPRO","SPRT","SPSC","SPTN","SPU","SPWRA","SPWRB","SQI","SQNM","SQQQ","SRCE","SRCL","SRDX","SREV","SRLS","SRSL","SSBI","SSFN","SSNC","SSRI","SSRX","SSYS","STAA","STAN","STBA","STBC","STBZ","STEC","STEI","STEL","STEM","STFC","STKL","STLD","STLY","STMP","STND","STNR","STON","STRA","STRC","STRL","STRM","STRN","STRS","STRT","STRZ","STSA","STX","STXS","SUBK","SUMR","SUNH","SUNS","SUPG","SUPX","SURG","SURW","SUSQ","SUSS","SUTR","SVA","SVBI","SVLF","SVNT","SVVC","SVVS","SWHC","SWIR","SWKS","SWSH","SWTX","SXCI","SYBT","SYBTP","SYKE","SYMC","SYMM","SYMS","SYMX","SYNA","SYNL","SYNM","SYNO","SYNT","SYPR","SYUT","TACT","TAIT","TASR","TAST","TATT","TAXI","TAYC","TAYCP","TAYD","TBAC","TBBK","TBET","TBNK","TBOW","TBSI","TBUS","TCBI","TCBIW","TCBK","TCCO","TCHC","TCLP","TCRD","TDBK","TDSC","TEAR","TECD","TECH","TECUA","TECUB","TELK","TESO","TESS","TEVA","TFCO","TFM","TFONY","TFSL","TGA","TGAL","TGE","TGIS","THFF","THLD","THOR","THQI","THRD","THRX","THTI","TIBB","TIBX","TICC","TIER","TIGR","TIII","TINY","TISA","TISI","TITN","TIVO","TKLC","TKMR","TLAB","TLCR","TLEO","TLF","TLGD","TLVT","TMNG","TNAV","TNCC","TNDM","TNGN","TO","TOBC","TOFC","TOMO","TOPS","TORM","TOWN","TPCG","TPGI","TQNT","TQQQ","TRAD","TRAK","TRBR","TRCI","TRCR","TREE","TRGL","TRGT","TRIB","TRID","TRIT","TRLG","TRMB","TRMD","TRMK","TRMS","TRNS","TRNX","TROW","TRS","TRST","TRUE","TSBK","TSCO","TSEM","TSEMG","TSLA","TSON","TSPT","TSRA","TSRI","TSRX","TST","TSTC","TSTF","TSTY","TSYS","TTEC","TTEK","TTGT","TTHI","TTMI","TTWO","TUES","TWER","TWGP","TWIN","TWMC","TWTC","TXCC","TXRH","TYPE","TZOO","TZYM","UACL","UBCP","UBFO","UBNK","UBOH","UBPSU","UBSH","UBSI","UCBA","UCBI","UCFC","UCTT","UDRL","UEIC","UEPS","UFCS","UFPI","UFPT","UG","UHAL","ULBI","ULGX","ULTA","ULTI","ULTR","UMBF","UMPQ","UNAM","UNB","UNFI","UNFY","UNIS","UNTD","UNTK","UNTY","UNXL","UPI","URBN","URRE","USAK","USAP","USAT","USATP","USATW","USATZ","USBI","USCR","USEG","USHS","USLM","USMO","USPH","USTR","UTEK","UTHR","UTIW","UTMD","UTSI","UVSP","VALU","VALV","VASC","VBFC","VCBI","VCIT","VCLK","VCLT","VCSH","VDSI","VECO","VELT","VGIT","VGLT","VGSH","VIAS","VICL","VICR","VIDE","VIFL","VIMC","VIRC","VISN","VIST","VITA","VIVO","VLCCF","VLCM","VLGEA","VLNC","VLTR","VLYWW","VMBS","VMED","VNDA","VNET","VNQI","VOCS","VOD","VOLC","VONE","VONG","VONV","VOXX","VPF","VPFG","VPHM","VPRT","VRA","VRGY","VRML","VRNM","VRNT","VRSK","VRSN","VRTA","VRTB","VRTS","VRTU","VRTX","VRUS","VSAT","VSBN","VSCI","VSCP","VSEA","VSEC","VSNT","VTAL","VTHR","VTNC","VTRO","VTSS","VTUS","VTWG","VTWO","VTWV","VVTV","VVUS","VXUS","VYFC","WABC","WACLY","WASH","WATG","WAVX","WAYN","WBCO","WBKC","WBMD","WBNK","WBSN","WBSTP","WCAA","WCBO","WCRX","WDFC","WEBM","WERN","WEST","WESTD","WEYS","WFD","WFM","WFMI","WFSL","WFSLW","WHRT","WIBC","WIFI","WILC","WIN","WINA","WINN","WIRE","WLB","WLBC","WLBPZ","WLDN","WLFC","WLFCP","WMAR","WMCO","WMGI","WOLF","WOOD","WOOF","WPCS","WPPGY","WPRT","WRES","WRLD","WRLS","WSB","WSBC","WSBF","WSCI","WSFS","WSTG","WSTL","WTBA","WTFC","WTFCW","WTNY","WTSLA","WUHN","WVFC","WVVI","WWAY","WWAYU","WWAYW","WWD","WWIN","WWON","WWVY","WWWW","WYNN","XATA","XBKS","XETA","XIDE","XIDEW","XING","XLNX","XNPT","XOMA","XPRT","XRAY","XRIT","XRTX","XTEX","XTXI","XWES","XXIA","YAVY","YDNT","YHOO","YONG","YORW","YRCW","YTEC","YUII","ZAGG","ZANE","ZBRA","ZEUS","ZGNX","ZHNE","ZIGO","ZINC","ZION","ZIONW","ZIOP","ZIP","ZIPR","ZIXI","ZLCS","ZN","ZNWAW","ZOLL","ZOLT","ZOOG","ZOOM","ZRAN","ZSTN","ZUMZ"
            };

            this.autoCompleteBox1.ItemsSource = tickerList;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bar.IsIndeterminate = true;
                this.ContentPanel.Children.Add(bar);

                String ticker = this.autoCompleteBox1.Text;

                AsyncCallback cb = new AsyncCallback(ServiceCallback);
                asyncWS.BeginGetQuote(ticker, cb, asyncWS);
            }
            catch (Exception)
            {
            }
        }

        public void ServiceCallback(IAsyncResult ar)
        {
            YahooServiceReference.StockQuoteSoap ws = (YahooServiceReference.StockQuoteSoapClient)ar.AsyncState;
            try
            {
                String soapResponse = ws.EndGetQuote(ar);

                result.symbol = soapResponse.Substring(soapResponse.IndexOf("<Symbol>") + 8, soapResponse.IndexOf("</Symbol>") - (soapResponse.IndexOf("<Symbol>") + 8));
                result.last = soapResponse.Substring(soapResponse.IndexOf("<Last>") + 6, soapResponse.IndexOf("</Last>") - (soapResponse.IndexOf("<Last>") + 6));
                result.date = soapResponse.Substring(soapResponse.IndexOf("<Date>") + 6, soapResponse.IndexOf("</Date>") - (soapResponse.IndexOf("<Date>") + 6));
                result.time = soapResponse.Substring(soapResponse.IndexOf("<Time>") + 6, soapResponse.IndexOf("</Time>") - (soapResponse.IndexOf("<Time>") + 6));
                result.change = soapResponse.Substring(soapResponse.IndexOf("<Change>") + 8, soapResponse.IndexOf("</Change>") - (soapResponse.IndexOf("<Change>") + 8));
                result.open = soapResponse.Substring(soapResponse.IndexOf("<Open>") + 6, soapResponse.IndexOf("</Open>") - (soapResponse.IndexOf("<Open>") + 6));
                result.high = soapResponse.Substring(soapResponse.IndexOf("<High>") + 6, soapResponse.IndexOf("</High>") - (soapResponse.IndexOf("<High>") + 6));
                result.low = soapResponse.Substring(soapResponse.IndexOf("<Low>") + 5, soapResponse.IndexOf("</Low>") - (soapResponse.IndexOf("<Low>") + 5));
                result.volume = soapResponse.Substring(soapResponse.IndexOf("<Volume>") + 8, soapResponse.IndexOf("</Volume>") - (soapResponse.IndexOf("<Volume>") + 8));
                result.MktCap = soapResponse.Substring(soapResponse.IndexOf("<MktCap>") + 8, soapResponse.IndexOf("</MktCap>") - (soapResponse.IndexOf("<MktCap>") + 8));
                result.prevClose = soapResponse.Substring(soapResponse.IndexOf("<PreviousClose>") + 15, soapResponse.IndexOf("</PreviousClose>") - (soapResponse.IndexOf("<PreviousClose>") + 15));
                result.ptgChange = soapResponse.Substring(soapResponse.IndexOf("<PercentageChange>") + 18, soapResponse.IndexOf("</PercentageChange>") - (soapResponse.IndexOf("<PercentageChange>") + 18));
                result.annRange = soapResponse.Substring(soapResponse.IndexOf("<AnnRange>") + 10, soapResponse.IndexOf("</AnnRange>") - (soapResponse.IndexOf("<AnnRange>") + 10));
                result.earns = soapResponse.Substring(soapResponse.IndexOf("<Earns>") + 7, soapResponse.IndexOf("</Earns>") - (soapResponse.IndexOf("<Earns>") + 7));
                result.P_E = soapResponse.Substring(soapResponse.IndexOf("<P-E>") + 5, soapResponse.IndexOf("</P-E>") - (soapResponse.IndexOf("<P-E>") + 5));
                result.name = soapResponse.Substring(soapResponse.IndexOf("<Name>") + 6, soapResponse.IndexOf("</Name>") - (soapResponse.IndexOf("<Name>") + 6));

                //Update UI
                Action _onUpdateAction = new Action(UpdateTicker);
                Dispatcher.BeginInvoke(_onUpdateAction);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error! Please try again later.", "Web Service is busy", MessageBoxButton.OK);
            }
        }

        protected void UpdateTicker()
        {
            this.txtTicker.Text = result.name;
            this.txtDate.Text = result.date;
            this.txtOpen.Text = result.open;
            this.txtHigh.Text = result.high;
            this.txtLow.Text = result.low;
            this.txtprevClose.Text = result.prevClose;
            this.txtVolume.Text = result.volume;
            this.txtChange.Text = result.change;
            this.txtLast.Text = result.last;
            this.txtPtgChange.Text = result.ptgChange;
            this.txtRange.Text = result.annRange;
            this.txtEarns.Text = result.earns;
            this.txtP_E.Text = result.P_E;

            this.ContentPanel.Children.Remove(bar);
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri(string.Format("/Views/ChartVN.xaml?opt={0}&sym={1}", 2, this.autoCompleteBox1.Text), UriKind.RelativeOrAbsolute));
        }
    }
}